import { GTextFormat } from "../../../../common/GTextFormat";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { QuestionList } from "./QuestionList";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
type int = number;
//class NpcTaskDialog
    
    export  class NpcTaskDialog /* flash.display.Sprite */
    {
        constructor(arg1: int)
        {
            
            this._width = arg1;
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._textFormat = new GTextFormat("", 12, 11661311);
            this._textFormat.leading = 1;
            this._textFormat.letterSpacing = 1;
            this._textField = new Object /* flash.text.TextField */();
            this._textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._textField.width = this.width;
            this._textField.mouseEnabled = false;
            this._textField.wordWrap = true;
            this._textField.multiline = true;
            this._textField.defaultTextFormat = this._textFormat;
            this._textField.filters = [FilterConst.nameGlowFilter];
            addChild(this._textField);
            this._questionList = new QuestionList();
            addChild(this._questionList);
            return;
        }

        protected createTitle(arg1: string): void
        {
            if (this._titleText == null) 
            {
                this._titleText = new Object /* flash.text.TextField */();
                this._titleText.defaultTextFormat = new GTextFormat("", 14, 5358160, true, null, null, null, null, flash.text.TextFormatAlign.CENTER);
                this._titleText.autoSize = flash.text.TextFieldAutoSize.CENTER;
                this._titleText.selectable = false;
                this._titleText.width = this.width;
                this._titleText.height = 35;
                this._titleText.filters = [FilterConst.nameGlowFilter];
            }
            this._titleText.text = arg1;
            this._titleText.x = (this.width - this._titleText.textWidth) / 2 - 10;
            this._titleText.y = 0;
            if (!this._titleText.parent) 
            {
                addChild(this._titleText);
            }
            this._titlePy = this._titleText.y + this._titleText.textHeight + 2;
            return;
        }

        public updateDialog(arg1: string, arg2: string=null, arg3: Array<any>=null): void
        {
            this._textField.htmlText = HTMLUtil.addColor(arg1, "#b1efff");
            this._titlePy = 5;
            if (arg2 != null) 
            {
                this.createTitle(arg2);
            }
            this._textField.y = this._titlePy;
            if (arg3 && !(arg3.length == 0)) 
            {
                this.updateQuestionList(arg3);
            }
            return;
        }

        public updateQuestionList(arg1: Array<any>): void
        {
            this._questionList.updateData(arg1);
            this._questionList.y = this._textField.y + this._textField.height + 10;
            return;
        }

        public updateHeight(arg1: int=1): void
        {
            this._heightStep = arg1;
            this._updateHeight = true;
            if (arg1 != 1) 
            {
                if (arg1 == 2) 
                {
                    this._titleText.y = 3;
                    this._titlePy = this._titleText.y + this._titleText.textHeight + 4;
                    this._textField.y = this._titlePy;
                    if (this._questionList && this._questionList.parent) 
                    {
                        this._questionList.y = this._textField.y + this._textField.height + 5;
                    }
                }
            }
            else 
            {
                this._titleText.y = 5;
                this._titlePy = this._titleText.y + this._titleText.textHeight + 7;
                this._textField.y = this._titlePy;
                if (this._questionList && this._questionList.parent) 
                {
                    this._questionList.y = this._textField.y + this._textField.height + 10;
                }
            }
            return;
        }

        public dispose(): void
        {
            if (this._titleText) 
            {
                if (contains(this._titleText)) 
                {
                    removeChild(this._titleText);
                }
                this._titleText.y = 0;
                this._titleText.text = "";
            }
            this._updateHeight = false;
            this._heightStep = 0;
            this._titlePy = 0;
            this._textField.text = "";
            this._questionList.dispose();
            return;
        }

        public /* override */ get height(): number
        {
            var loc1=this._textField.y + this._textField.textHeight + this._questionList.height;
            if (this._updateHeight) 
            {
                if (this._heightStep != 1) 
                {
                    if (this._heightStep == 2) 
                    {
                        loc1 = loc1 + 3;
                    }
                }
                else 
                {
                    loc1 = loc1 + 5;
                }
            }
            return loc1;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        /* internal */ /* var */_textFormat: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_titleText: Object /* flash.text.TextField */;

        /* internal */ /* var */_textField: Object /* flash.text.TextField */;

        /* internal */ /* var */_questionList: QuestionList;

        /* internal */ /* var */_titlePy: int;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_updateHeight: Boolean;

        /* internal */ /* var */_heightStep: int;
    }
